<template>
  <div id="accomplishClaim">
    <H1>完成的理赔</H1>
    <div style="margin-bottom: 10px">
      <el-input v-model="input" placeholder="请输入订单号"></el-input>
      <el-button type="primary" style="margin-left: 10px" @click="search"
        >搜索</el-button
      >
    </div>
    <el-table :data="tableData" border style="width: 100%"  :header-cell-style="{textAlign: 'center'}" :cell-style="{ textAlign: 'center' }">
      <el-table-column fixed prop="_id" label="理赔单号"> </el-table-column>
      <el-table-column prop="applyDate" label="申请时间"> </el-table-column>
      <el-table-column prop="troubleDate" label="事故时间"> </el-table-column>
      <el-table-column prop="state" label="理赔状态">
        <template slot-scope="scope">
          <span v-if="scope.row.state == 3">审核不通过</span>
          <span v-else-if="scope.row.state == 2">审核通过</span>
        </template>
      </el-table-column>
      <el-table-column prop="claimsImages" label="理赔图片">
        <template slot-scope="scope">
          <img
            :src="'http://localhost:3000/images/' + scope.row.claimsImages"
            alt=""
            width="70px"
          />
        </template>
      </el-table-column>
      <el-table-column prop="order" label="所属订单"> </el-table-column>
    </el-table>
    <div class="block">
      <span class="demonstration">完整功能</span>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[3, 6, 9]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totals"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
let { mapState, mapActions, mapMutations } = createNamespacedHelpers(
  "accomplish"
);
export default {
  data() {
    return {
      currentPage: 1,
      pageSize: 3,
      input: "",
    };
  },
  mounted() {
    this.getFinishClaimApply({ pageSize: 3 });
  },
  computed: {
    ...mapState(["tableData", "totals"]),
  },
  methods: {
    ...mapMutations(["setInput"]),
    ...mapActions(["getFinishClaimApply"]),
    handleClick(row) {
      console.log(row);
    },
    //分页功能开始
    handleSizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.getFinishClaimApply({
        pageSize: val,
        currentPage: this.currentPage,
        _id: this.input,
      });
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getFinishClaimApply({
        pageSize: this.pageSize,
        currentPage: val,
        _id: this.input,
      });
    },
    search() {
      this.getFinishClaimApply({
        pageSize: this.pageSize,
        currentPage: this.currentPage,
        _id: this.input,
      });
    },
    //分页功能结束
  },
};
</script>

<style scoped lang='scss'>
#accomplishClaim {
  .el-input {
    width: 200px;
  }

}
</style>